/**
 * Created by lz on 2017/4/27.
 */
import Reflux from 'reflux';
import Action from './action';
import Ajax from '../../utils/ajax';

let store = Reflux.createStore({
    listenables: Action,

    onGetDetail(id, callback){
        let param = {
            book_id: id
        };
        Ajax.get('?c=main&a=book',param).then(function (response) {
            var obj = response.data;
            callback(obj);
        }).catch(function (error) {
            console.log(error);
        });
    },

    onGetArticle(path, id, callback){
        let param = {
            book_path: path,
            id: id
        };
        Ajax.get('?c=main&a=article',param).then(function (response) {
            var obj = response.data;
            callback(obj);
        }).catch(function (error) {
            console.log(error);
        });
    },
});

export default store;